﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TowerDefender.Model;

namespace TowerDefender.Entities
{
    public class Peon
    {
        private Coordinates _coordinates;
        private int positionInMapPath = 0;
        public int _speed;
        private Engine _engine;
        private bool _inMotion;
        public event EventHandler CoordinatesChanged;

        public Peon(Map map, int speed)
        {
            _inMotion = false;
            _speed = speed;
            PeonMap = map;
            _coordinates = PeonMap.MapPath.Steps[0];
        }

        public Map PeonMap { get; set; }

        public int PositionInMapPath
        {
            get { return positionInMapPath; }
            set 
            { 
                positionInMapPath = value;
                if (positionInMapPath < PeonMap.MapPath.Steps.Count)
                {
                    coordinates = PeonMap.MapPath.Steps[positionInMapPath];
                }
            }
        }
        public Engine engine 
        {
            get { return _engine; }
        }
        
        public bool InMotion
        {
            get { return _inMotion; }
            set { _inMotion = value; }
        }

        public Coordinates coordinates 
        {
            get
            {
                return _coordinates;
            }
            set 
            { 
                _coordinates = value;
                if (CoordinatesChanged != null)
                {
                    CoordinatesChanged(this, new EventArgs());
                }
            }
        }

        
        
       

        
    }
}
